﻿using System;
using UnityEngine;

namespace RootMotion
{
	// Token: 0x020000F7 RID: 247
	public static class QuaTools
	{
		// Token: 0x0600070C RID: 1804 RVA: 0x0000681D File Offset: 0x00004A1D
		public static Quaternion LinearBlend(Quaternion q, float weight)
		{
			if (weight <= 0f)
			{
				return Quaternion.identity;
			}
			if (weight >= 1f)
			{
				return q;
			}
			return Quaternion.Lerp(Quaternion.identity, q, weight);
		}

		// Token: 0x0600070D RID: 1805 RVA: 0x00006849 File Offset: 0x00004A49
		public static Quaternion SphericalBlend(Quaternion q, float weight)
		{
			if (weight <= 0f)
			{
				return Quaternion.identity;
			}
			if (weight >= 1f)
			{
				return q;
			}
			return Quaternion.Slerp(Quaternion.identity, q, weight);
		}

		// Token: 0x0600070E RID: 1806 RVA: 0x0003DCDC File Offset: 0x0003BEDC
		public static Quaternion FromToAroundAxis(Vector3 fromDirection, Vector3 toDirection, Vector3 axis)
		{
			Quaternion quaternion = Quaternion.FromToRotation(fromDirection, toDirection);
			float num = 0f;
			Vector3 zero = Vector3.zero;
			quaternion.ToAngleAxis(out num, out zero);
			float num2 = Vector3.Dot(zero, axis);
			if (num2 < 0f)
			{
				num = -num;
			}
			return Quaternion.AngleAxis(num, axis);
		}

		// Token: 0x0600070F RID: 1807 RVA: 0x00006875 File Offset: 0x00004A75
		public static Quaternion RotationToLocalSpace(Quaternion space, Quaternion rotation)
		{
			return Quaternion.Inverse(Quaternion.Inverse(space) * rotation);
		}

		// Token: 0x06000710 RID: 1808 RVA: 0x00006888 File Offset: 0x00004A88
		public static Quaternion FromToRotation(Quaternion from, Quaternion to)
		{
			if (to == from)
			{
				return Quaternion.identity;
			}
			return to * Quaternion.Inverse(from);
		}

		// Token: 0x06000711 RID: 1809 RVA: 0x0003DD28 File Offset: 0x0003BF28
		public static Vector3 GetAxis(Vector3 v)
		{
			Vector3 vector = Vector3.right;
			bool flag = false;
			float num = Vector3.Dot(v, Vector3.right);
			float num2 = Mathf.Abs(num);
			if (num < 0f)
			{
				flag = true;
			}
			float num3 = Vector3.Dot(v, Vector3.up);
			float num4 = Mathf.Abs(num3);
			if (num4 > num2)
			{
				num2 = num4;
				vector = Vector3.up;
				flag = (num3 < 0f);
			}
			float num5 = Vector3.Dot(v, Vector3.forward);
			num4 = Mathf.Abs(num5);
			if (num4 > num2)
			{
				vector = Vector3.forward;
				flag = (num5 < 0f);
			}
			if (flag)
			{
				vector = -vector;
			}
			return vector;
		}
	}
}
